//Author:YasinKutuk,AdilUsturali
//Date:01Agu2017
//Encoding:UTF-8


//Program Definition
program define protest.paper



//Protest Study
set more off
vers
*Genelde veriler Wave5 ve Wave6 icin var

import excel "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\03.Data\Wave7FreedomHouseCoded.xlsx", sheet("Sheet1") firstrow clear


keep CountryId Type_Wave
save "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\03.Data\Adil_Classification.dta", replace

use "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\_WVS\WVS_TimeSeries_1981_2020_stata_v2_0.dta", clear
gen CountryId=S003

merge m:1 CountryId using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\03.Data\Adil_Classification.dta" 

*CONFIDENCE (***:Bu paper'da islediklerimiz )

*E069_01	Confidence: Churches 
***E069_02	Confidence: Armed Forces 
*E069_03	Confidence: Education System 
*E069_04	Confidence: The Press 
*E069_05	Confidence: Labour Unions 
***E069_06	Confidence: The Police 
***E069_07	Confidence: Parliament 
*E069_08	Confidence: The Civil Services 
*E069_09	Confidence: Social Security System 
*E069_10	Confidence: Television 
***E069_11	Confidence: The Government 
***E069_12	Confidence: The Political Parties 
*E069_13	Confidence: Major Companies 
*E069_14	Confidence: The Environmental Protection Movement 
*E069_15	Confidence: The Women's Movement 
***E069_17	Confidence: Justice System/Courts 

*ACTIONS
***E025	Political action: signing a petition
*E025B	Political action recently done: signing a petition
*E026	Political action: joining in boycotts
*E026B	Political action recently done: joining in boycotts
***E027	Political action: attending lawful/peaceful demonstrations
***E028	Political action: joining unofficial strikes
*E028B	Political acition recently done: Joining strikes
*E029	Political action: occupying buildings or factories
*E030	Political action: damaging things, breaking windows, street violence
*E031	Political action: personal violence


//Sirali country identification
decode S003, gen(country_name)
encode country_name,gen(ccode)


//Variables
ren E025 petition
ren E026 boycotts
ren E027 demonst
ren E028 strikes
ren E069_07 parliament
ren E069_11 govt
ren E069_12 polpart
ren E069_17 justice
ren E069_02 armed
ren E069_06 police
ren S002 Wave

//Global Variables
global allvars parliament govt polpart justice armed police petition boycotts demonst strikes
global confid parliament govt polpart justice armed police 
global action petition boycotts demonst strikes 


//Restriction - Sadece son 6 Wave'i aliyoruz
keep if Wave>1 


//Restriction - Negative degerleri atiyorum
foreach z of global allvars {
	replace `z'=. if `z'<0
}

drop if Type_Wave==.

gen Type2 = 1 if Type_Wave==2
replace Type2 = 0 if Type_Wave==0 | Type_Wave==1 


//Strikes 1st Wave imputation - sadece Guttman hesaplarken dikkate alınacak
impute strikes parliament govt polpart justice armed police petition boycotts demonst, generate(strikes2) copyrest
gen strikes3=1 if strikes2<1.9999999999
replace strikes3=2 if strikes2>=2 & strikes2<2.99999999999
replace strikes=3 if strikes2>=3
replace strikes3=strikes if Wave!=5

//Justice 4th Wave imputation - sadece Guttman hesaplarken dikkate alınacak
impute justice parliament govt polpart justice armed police petition boycotts demonst, generate(justice2) copyrest
gen justice3=1 if justice2<1.75 & Wave==4
replace justice3=2 if justice2>=1.75 & justice2<2.40 & Wave==4
replace justice3=3 if justice2>=2.40 & justice2<3.10 & Wave==4
replace justice3=4 if justice2>=3.10 & Wave==4
replace justice3=justice if Wave!=4

//Global Variables-Tekrar
global allvars parliament govt polpart justice armed police petition boycotts demonst strikes strikes3 justice3
global confid parliament govt polpart justice justice3 armed police 
global action petition boycotts demonst strikes strikes3 

order $allvars, after(ccode)


//Polarized ve Grouped Actions
foreach var of global action{
gen `var'_pol=1 if `var'==1
replace `var'_pol=0 if `var'==3
}

foreach var of global action{
gen `var'_gr=0 if `var'==3 
replace `var'_gr=1 if `var'<3
}


//Global Variables
global action_pol petition_pol boycotts_pol demonst_pol strikes_pol //pol means Polarized
global action_gr petition_gr boycotts_gr demonst_gr strikes_gr //gr mean Grouped



//Modification - Scaling'i degistiriyorum Confidence sorulari icin, 
foreach x of global confid { 
replace `x'=44 if `x'==1
replace `x'=33 if `x'==2
replace `x'=22 if `x'==3
replace `x'=11 if `x'==4
replace `x'=4 if `x'==44
replace `x'=3 if `x'==33
replace `x'=2 if `x'==22
replace `x'=1 if `x'==11
}

foreach x of global action { 
replace `x'=33 if `x'==1
replace `x'=22 if `x'==2
replace `x'=11 if `x'==3
replace `x'=3 if `x'==33
replace `x'=2 if `x'==22
replace `x'=1 if `x'==11
}





label define Type_Wave 0 "NonDemocratic"  1 "Mixed Regime "  2 "Democratic" 
label val Type_Wave Type_Wave

label define Type2 0 "NonDemocratic"  1 "Democratic" 
label val Type2 type2

//Guttman Scaling Outputs
gen gutt_instrust=parliament+govt+polpart+justice+armed+police
gen gutt_instrust3=parliament+govt+polpart+justice3+armed+police

gen gutt_action=petition+boycotts+demonst
gen gutt_action3=petition+boycotts+demonst

gen gutt_action_pol=petition_pol+boycotts_pol+demonst_pol+strikes_pol
gen gutt_action3_pol=petition_pol+boycotts_pol+demonst_pol+strikes3_pol

gen gutt_action_gr=petition_gr+boycotts_gr+demonst_gr+strikes_gr
gen gutt_action3_gr=petition_gr+boycotts_gr+demonst_gr+strikes3_gr

gen gutt_action4=petition+boycotts+demonst
gen gutt_action4_pol=petition_pol+boycotts_pol+demonst_pol
gen gutt_action4_gr=petition_gr+boycotts_gr+demonst_gr


//Action Coding - at least one action
gen act=1 if gutt_action_pol>=1
replace act=0 if gutt_action_pol==0

gen act_pol=1 if gutt_action_pol==4
replace act_pol=0 if gutt_action_pol<4

//Political Activity
generate polactivity=1 if boycotts==3 | demonst==3 | petition==3
replace polactivity=0 if polactivity==.

//Political Activity3
generate polactivity3=1 if boycotts==3 | demonst==3 | petition==3
replace polactivity3=0 if polactivity3==.


*02.Agu.2017
//Labeling Guttman and Action Vars
label var gutt_instrust "Political Trust-Guttman"
label var gutt_instrust3 "Political Trust-Guttman"
label var gutt_action "Political Action-Guttman"
label var gutt_action_pol "Political Action Polarized-Guttman"
label var gutt_action_gr "Political Action Mean-Guttman"
label var gutt_action4 "Political Action-Guttman"
label var gutt_action4_pol "Political Action Polarized-Guttman"
label var gutt_action4_gr "Political Action Mean-Guttman"

label var act "Action (Any)"
label var act_pol "Action (All)"


**************************************************************************************************************

//R'da tablolar yapmak için
order S010, after(act_pol)
rename S010 cabbrev
drop S006-Y024C

//Squared vars
foreach var of varlist parliament govt polpart justice justice3 armed police gutt_instrust gutt_instrust3 {
gen `var'_sq=`var'^2
}


//Modification of var labels
label var parliament_sq "Squared Conf.Parliament"
label var govt_sq "Squared Conf.Gov't"
label var polpart_sq "Squared Conf.PolParties"
label var armed_sq "Squared Conf.ArmedForces"
label var justice_sq "Squared Conf.JusticeSystem"
label var justice3_sq "Squared Conf.JusticeSystem"
label var police_sq "Squared Conf.Police"
label var gutt_instrust_sq "Squared Political Trust"
label var gutt_instrust3_sq "Squared Political Trust"


//Tabulation for Dummies
gen Wave2 = 1 if Wave == 2
replace Wave2 = 0 if Wave2==.

gen Wave3 = 1 if Wave == 3
replace Wave3 = 0 if Wave3==.

gen Wave4 = 1 if Wave == 4
replace Wave4 = 0 if Wave4==.

gen Wave5 = 1 if Wave == 5
replace Wave5 = 0 if Wave5==.

gen Wave6 = 1 if Wave == 6
replace Wave6 = 0 if Wave6==.

gen Wave7 = 1 if Wave == 7
replace Wave7 = 0 if Wave7==.



tab ccode , gen(DCountry_)
tab Type_Wave , gen(DType_)
tab Type2 , gen(DType2_)

//Manual base settings for dummies
global dwave DWave_5 DWave_4 DWave_3 DWave_2 DWave_1
global dcountry  DCountry_80	 DCountry_79	 DCountry_78	 DCountry_77	 DCountry_76	 DCountry_75	 DCountry_74	 DCountry_73	 DCountry_72	 DCountry_71	 DCountry_70	 DCountry_69	 DCountry_68	 DCountry_67	 DCountry_66	 DCountry_65	 DCountry_64	 DCountry_63	 DCountry_62	 DCountry_61	 DCountry_60	 DCountry_59	 DCountry_58	 DCountry_57	 DCountry_56	 DCountry_55	 DCountry_54	 DCountry_53	 DCountry_52	 DCountry_51	 DCountry_50	 DCountry_49	 DCountry_48	 DCountry_47	 DCountry_46	 DCountry_45	 DCountry_44	 DCountry_43	 DCountry_42	 DCountry_41	 DCountry_40	 DCountry_39	 DCountry_38	 DCountry_37	 DCountry_36	 DCountry_35	 DCountry_34	 DCountry_33	 DCountry_32	 DCountry_31	 DCountry_30	 DCountry_29	 DCountry_28	 DCountry_27	 DCountry_26	 DCountry_25	 DCountry_24	 DCountry_23	 DCountry_22	 DCountry_21	 DCountry_20	 DCountry_19	 DCountry_18	 DCountry_17	 DCountry_16	 DCountry_15	 DCountry_14	 DCountry_13	 DCountry_12	 DCountry_11	 DCountry_10	 DCountry_9	 DCountry_8	 DCountry_7	 DCountry_6	 DCountry_5	 DCountry_4	 DCountry_3	 DCountry_2	 DCountry_1
global dType DType_3 DType_2 DType_1

//Labelling again
label variable Wave2 "W.1989-1993"
label variable Wave3 "W.1994-1998"
label variable Wave4 "W.1999-2004"
label variable Wave5 "W.2005-2009"
label variable Wave6 "W.2010-2014"
label variable Wave7 "W.2017-2020"

label variable DType_1 "NonDemocratic"
label variable DType_2 "Mixed Regime"
label variable DType_3 "Democratic"

label variable DType2_1 "NonDemocratic"
label variable DType2_2 "Democratic"


save preserved.dta,replace


**************************************************************************************************************
//Ordered Logit Regression - Guttman Scaling results
use preserved.dta,clear


use "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\_WVS\preserved.dta", clear


//Variable Rename
ren gutt_action_pol action

// Keep only Wave 7
keep if Wave==7


// Missing Values Drop
egen miss = rowmiss(action act_pol parliament - strikes)
drop if miss>0


// Trust Variable
gen trust = parliament + govt + polpart + justice + armed + police
egen trust_mean = rowmean(parliament govt polpart justice armed police) 

gen trust_sq = trust^2
gen trust_mean_sq =trust_mean^2



//Global Variables
global allvars parliament govt polpart justice armed police petition boycotts demonst strikes
global trustvar trust trust_mean parliament govt polpart justice armed police 
global std_trust std_trust std_trust_mean 
global actionvar petition boycotts demonst strikes 


//Missing Analysis
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\MissingAnalysis.txt", text replace
foreach var of global trustvar{
display as text `***'
display as text `var'
tab COW_ALPHA `var' , missing
display as text `***'
}
log close


//Standardized Trust Variables
encode COW_ALPHA, gen(countrycode)

foreach var of global trustvar{
	forvalues i=1(1)50{
		su `var' if countrycode==`i'
		cap noi:gen std_`var' = (`var' - r(min)) / (r(max) - r(min)) if countrycode==`i'
		cap noi:replace std_`var' = (`var' - r(min)) / (r(max) - r(min)) if countrycode==`i'
	}
}



//  Standardized Trust Variable
drop std_trust std_trust_mean
gen std_trust = std_parliament + std_govt + std_polpart + std_justice + std_armed + std_police
egen std_trust_mean= rowmean(std_parliament  std_govt  std_polpart  std_justice  std_armed  std_police) 

gen std_trust_sq = std_trust^2
gen std_trust_mean_sq = std_trust_mean^2



//For Dummy of Democratic Countries
ren DType2_2 democr

gen nondemocr = 1 if democr==0
replace nondemocr = 0 if democr==1


foreach var of global trustvar {
gen `var'_democr = `var' * democr
gen `var'_sq_democr = `var'_sq * democr

gen `var'_nondemocr = `var' * nondemocr
gen `var'_sq_nondemocr = `var'_sq * nondemocr
}




//Trust Variable and Democratic Countries
foreach var of global std_trust {
gen `var'_democr = `var' * democr
gen `var'_sq_democr = `var'_sq * democr

gen `var'_nondemocr = `var' * nondemocr
gen `var'_sq_nondemocr = `var'_sq * nondemocr
}







//Labelling
cap noi: label define confid 4 "A great deal" 3 "Quite a lot" 2 "Not very much" 1 "None at all"
label values parliament govt polpart justice armed police confid 

label var parliament "Trust to Parliament"
label var govt "Trust to Government"
label var polpart "Trust to Political Parties"
label var justice "Trust to Justice System"
label var armed "Trust to Armed Forces"
label var police "Trust to Police"
label var parliament_sq "Trust to Parliament Squared"
label var govt_sq "Trust to Government Squared"
label var polpart_sq "Trust to Political Parties Squared"
label var justice_sq "Trust to Justice System Squared"
label var armed_sq "Trust to Armed Forces Squared"
label var police_sq "Trust to Police Squared"

label var petition "Action Petition"
label var boycotts "Action Boycotts"
label var demonst "Action Demonst"
label var strikes "Action Strikes"

label var action "# of Actions"


cap noi: label define democr 0 "Non-Democratic" 1 "Democratic"
label values petition democr democr 
label var democr "Regime"

cap noi: label define action 3 "Have Done" 2 "Might do" 1 "Would never do"
label values petition boycotts demonst strikes action
cap noi: label define polar 1 "Have done" 0 "Would never do"
cap noi: label define group 1 "Have done/ Might do" 0 "Would never do"
label values petition_pol boycotts_pol demonst_pol strikes_pol polar
label values petition_gr boycotts_gr demonst_gr strikes_gr group
label var petition_pol "Act.Petition.Polar"
label var boycotts_pol "Act.Boycotts.Polar"
label var demonst_pol "Act.Demonst.Polar"
label var strikes_pol "Act.Strikes.Polar"
label var petition_gr "Act.Petition.Group"
label var boycotts_gr "Act.Boycotts.Group"
label var demonst_gr "Act.Demonst.Group"
label var strikes_gr "Act.Strikes.Group"


label var std_trust "Normalized Trust Sum"
label var std_trust_mean "Normalized Trust Mean"
label var std_trust_sq "Normalized Trust Squared"
label var std_trust_mean_sq "Normalized Trust Mean Squared"
label var nondemocr "Non-Democratic"
label var trust_democr "Trust Sum Democratic"
label var trust_sq_democr "Trust Sum Squared Democratic"
label var trust_nondemocr "Trust Sum Squared Non-Democratic"
label var trust_sq_nondemocr "Trust Sum Squared Non-Democratic"
label var trust_mean_democr "Trust Mean Democratic"
label var trust_mean_sq_democr "Trust Mean Squared Democratic"
label var trust_mean_nondemocr "Trust Mean Squared Non-Democratic"
label var trust_mean_sq_nondemocr "Trust Mean Squared Non-Democratic"
label var parliament_democr "Trust to Parliament Democratic"
label var parliament_sq_democr "Trust to Parliament Squared Democratic"
label var parliament_nondemocr "Trust to Parliament Non-Democratic"
label var parliament_sq_nondemocr "Trust to Parliament Squared Non-Democratic"
label var govt_democr "Trust to Government Democratic"
label var govt_sq_democr "Trust to Government Squared Democratic"
label var govt_nondemocr "Trust to Government Non-Democratic"
label var govt_sq_nondemocr "Trust to Government Squared Non-Democratic"
label var polpart_democr "Trust to Political Parties Democratic"
label var polpart_sq_democr "Trust to Political Parties Squared Democratic"
label var polpart_nondemocr "Trust to Political Parties Non-Democratic"
label var polpart_sq_nondemocr "Trust to Political Parties Squared Non-Democratic"
label var justice_democr "Trust to Justice System Democratic"
label var justice_sq_democr "Trust to Justice System Squared Democratic"
label var justice_nondemocr "Trust to Justice System Non-Democratic"
label var justice_sq_nondemocr "Trust to Justice System Squared Non-Democratic"
label var armed_democr "Trust to Armed Forces Democratic"
label var armed_sq_democr "Trust to Armed Forces Squared Democratic"
label var armed_nondemocr "Trust to Armed Forces Non-Democratic"
label var armed_sq_nondemocr "Trust to Armed Forces Squared Non-Democratic"
label var police_democr "Trust to Police Democratic"
label var police_sq_democr "Trust to Police Squared Democratic"
label var police_nondemocr "Trust to Police Non-Democratic"
label var police_sq_nondemocr "Trust to Police Squared Non-Democratic"
label var std_trust_democr "Normalized Trust Sum Democratic"
label var std_trust_sq_democr "Normalized Trust Sum Squared Democratic"
label var std_trust_nondemocr "Normalized Trust Sum Non-Democratic"
label var std_trust_sq_nondemocr "Normalized Trust Sum Squared Non-Democratic"




//Main Model
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\10.StdTrust.txt", text replace
*;Trust normalized 
display as text "*** Standardized Trust Sum ***"
est clear
poisson action std_trust std_trust_sq, robust
utest std_trust std_trust_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol std_trust std_trust_sq, robust
utest std_trust std_trust_sq, prefix(act_pol)
*est sto poi02
mfx
est sto mfx02

poisson action std_trust_democr std_trust_sq_democr std_trust_nondemocr std_trust_sq_nondemocr, robust
utest  std_trust_democr std_trust_sq_democr, prefix(action )
utest  std_trust_nondemocr std_trust_sq_nondemocr, prefix(action)
*est sto poi03
mfx
est sto mfx03

logit act_pol std_trust_democr std_trust_sq_democr std_trust_nondemocr std_trust_sq_nondemocr, robust
utest  std_trust_democr std_trust_sq_democr, prefix(act_pol )
utest  std_trust_nondemocr std_trust_sq_nondemocr, prefix(act_pol)
*est sto poi04
mfx
est sto mfx04

esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\10.StdTrust.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close



//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\11.Parliament.txt", text replace
display as text "*** Parliament ***"
est clear
poisson action parliament parliament_sq, robust
utest parliament parliament_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol parliament parliament_sq, robust
utest parliament parliament_sq, prefix(act_pol)
*est sto poi02
mfx
est sto mfx02

poisson action parliament_democr parliament_sq_democr parliament_nondemocr parliament_sq_nondemocr, robust
utest parliament_democr parliament_sq_democr, prefix(action)
utest parliament_nondemocr parliament_sq_nondemocr, prefix(action)
*est sto poi03
mfx
est sto mfx03

logit act_pol parliament_democr parliament_sq_democr  parliament_nondemocr parliament_sq_nondemocr, robust
utest parliament_democr parliament_sq_democr, prefix(act_pol)
utest parliament_nondemocr parliament_sq_nondemocr, prefix(act_pol)
*est sto poi04
mfx
est sto mfx04

esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\11.Parliament.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close



//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\12.Govt.txt", text replace
display as text "*** Govt ***"
est clear
poisson action govt govt_sq, robust
utest govt govt_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol govt govt_sq, robust
utest govt govt_sq, prefix(act_pol)
*est sto poi03
mfx
est sto mfx02
**
poisson action govt_democr govt_sq_democr govt_nondemocr govt_sq_nondemocr, robust
utest govt_democr govt_sq_democr , prefix(action)
utest govt_nondemocr govt_sq_nondemoc, prefix(action)
*est sto poi03
mfx
est sto mfx03

logit act_pol govt_democr govt_sq_democr govt_nondemocr govt_sq_nondemocr , robust
utest govt_democr govt_sq_democr , prefix(act_pol)
utest govt_nondemocr govt_sq_nondemocr , prefix(act_pol)
*est sto poi04
mfx
est sto mfx04


esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\12.Govt.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close



//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\13.PolPart.txt", text replace
display as text "*** PolParties ***"
est clear
poisson action polpart polpart_sq, robust
utest polpart polpart_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol polpart polpart_sq, robust
utest polpart polpart_sq, prefix(act_pol)
*est sto poi03
mfx
est sto mfx02
**
poisson action polpart_democr polpart_sq_democr polpart_nondemocr polpart_sq_nondemocr , robust
utest polpart_democr polpart_sq_democr, prefix(action)
utest polpart_nondemocr polpart_sq_nondemocr, prefix(action)
*est sto poi02
mfx
est sto mfx03

logit act_pol polpart_democr polpart_sq_democr polpart_nondemocr polpart_sq_nondemocr, robust
utest polpart_democr polpart_sq_democr , prefix(act_pol)
utest polpart_nondemocr polpart_sq_nondemocr, prefix(act_pol)
*est sto poi04
mfx
est sto mfx04

esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\13.PolPart.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close




//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\14.Justice.txt", text replace
display as text "*** Justice ***"
est clear
poisson action justice justice_sq, robust
utest justice justice_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol justice justice_sq, robust
utest justice justice_sq, prefix(act_pol)
*est sto poi03
mfx
est sto mfx02

**
poisson action justice_democr justice_sq_democr justice_nondemocr justice_sq_nondemocr , robust
utest justice_democr justice_sq_democr, prefix(action)
utest justice_nondemocr justice_sq_nondemocr , prefix(action)
*est sto poi02
mfx
est sto mfx03

logit act_pol justice_democr justice_sq_democr justice_nondemocr justice_sq_nondemocr, robust
utest justice_democr justice_sq_democr, prefix(act_pol)
utest justice_nondemocr justice_sq_nondemocr , prefix(act_pol)
*est sto poi04
mfx
est sto mfx04

esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\14.Justice.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close



//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\15.ArmedForces.txt", text replace
display as text "*** ArmedForces ***"
est clear
poisson action armed armed_sq, robust
utest  armed armed_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01

logit act_pol armed armed_sq, robust
utest  armed armed_sq, prefix(act_pol)
*est sto poi03
mfx
est sto mfx02

**
poisson action armed_democr armed_sq_democr armed_nondemocr armed_sq_nondemocr, robust
utest armed_democr armed_sq_democr , prefix(action)
utest armed_nondemocr armed_sq_nondemocr, prefix(action)
*est sto poi02
mfx
est sto mfx03

logit act_pol armed_democr armed_sq_democr armed_nondemocr armed_sq_nondemocr, robust
utest armed_democr armed_sq_democr , prefix(act_pol)
utest armed_nondemocr armed_sq_nondemocr, prefix(act_pol)
*est sto poi04
mfx
est sto mfx04

esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\15.ArmedForces.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close




//Basic Models
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\16.Police.txt", text replace
display as text "*** Police ***"
est clear
poisson action police police_sq, robust
utest police police_sq, prefix(action)
*est sto poi01
mfx
est sto mfx01


logit act_pol police police_sq, robust
utest police police_sq, prefix(act_pol)
*est sto poi03
mfx
est sto mfx02
**
poisson action police_democr police_sq_democr  police_nondemocr police_sq_nondemocr, robust
utest police_democr police_sq_democr , prefix(action)
utest police_nondemocr police_sq_nondemocr, prefix(action)
*est sto poi02
mfx
est sto mfx03

logit act_pol police_democr police_sq_democr police_nondemocr police_sq_nondemocr, robust
utest police_democr police_sq_democr , prefix(act_pol)
utest police_nondemocr police_sq_nondemocr, prefix(act_pol)
*est sto poi04
mfx
est sto mfx04


esttab * using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\16.Police.rtf", label ///
mtitles("Political Action (PRME)" "Prob[Action] (LRME)" "Political Action (PRME)" "Prob[Action] (LRME)" ) ///
collabels(none) eqlabels(none) ///
replace margin cells(b(star fmt(3)) t(par fmt(2))) stats(N chi2 p r2_p, fmt(%9.0f %9.4g %9.4f %9.4f) labels("Obs." "Chi-Squared" "Prob-Chi-Sq" "Pseduo R-Squared" ) ) ///
note("PRME stands for Poisson Regression Marginal Effects while LRME is Logit Regression Marginal Effects. z statistics in parentheses, * p<0.05, ** p<0.01, *** p<0.001). Standart errors are Eicker–Huber–White's heteroskedasticity-robust standard errors.")

log close




//Graphical Appendicies
twoway (qfit action std_trust_democr,  lpattern(dash)) ///
(qfit action std_trust_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust Sum", margin(small)) ///
title("Curvilinearity of Normalized Trust Sum")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\10.TrustSum.png" ,as(png) replace


twoway (qfit action parliament_democr,  lpattern(dash)) ///
(qfit action parliament_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Parliament", margin(small)) ///
title("Curvilinearity of Trust to Parliament")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\11.Parliament.png" ,as(png) replace


twoway (qfit action govt_democr,  lpattern(dash)) ///
(qfit action govt_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Government", margin(small)) ///
title("Curvilinearity of Trust to Government")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\12.Govt.png" ,as(png) replace


twoway (qfit action polpart_democr,  lpattern(dash)) ///
(qfit action polpart_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Political Parties", margin(small)) ///
title("Curvilinearity of Trust to Political Parties")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\13.PolPart.png" ,as(png) replace



twoway (qfit action justice_democr,  lpattern(dash)) ///
(qfit action justice_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Justice", margin(small)) ///
title("Curvilinearity of Trust to Justice")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\14.Justice.png" ,as(png) replace


twoway (qfit action armed_democr,  lpattern(dash)) ///
(qfit action armed_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Armed Forces", margin(small)) ///
title("Curvilinearity of Trust to Armed Forces")  /// xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\15.Armed.png" ,as(png) replace



twoway (qfit action police_democr,  lpattern(dash)) ///
(qfit action police_nondemocr,  lpattern(vshortdash)), ///
ytitle("# of Political Action", margin(medium)) xtitle("Trust to Police", margin(small)) ///
title("Curvilinearity of Trust to Police") ///  xsize(20) ysize(15) scale(0.8) ylabel(0(1)4) ///
scheme(sj) legend(order(1 "Democratic" 2 "Non-Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\16.Police.png" ,as(png) replace


log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\MissingAnalysis.txt", text replace
foreach var of global trustvar{
display as text `***'
display as text `var'
tab COW_ALPHA `var' , missing
display as text `***'
}
log close


//Descriptives of All Variables
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\01.Descriptives.txt", text replace

asdoc sum std_trust  action parliament govt polpart justice armed police, ///
stat(N min mean p50 max sd)  by(democr) replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\01.Descriptives.rtf)



tabstat std_trust  action parliament govt polpart justice armed police, ///
stats(n min mean p50 max sd) columns(statistics) by(democr)

log close


//Certain Tabulations
cap noi: cd d:/
log using "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02.Tabulations.txt", text replace
display as text "***************"
display as text "How many democratic countries are there?"
asdoc tabulate democ, ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02.a.Tab-Countries.rtf)




display as text "***************"
display as text "Actions vs Parliament"
asdoc tabulate action parliament, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02b.Tab-Parliament.rtf)
display as text "***************"


display as text "***************"
display as text "Actions vs Government"
asdoc tabulate action govt, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02c.Tab-Govt.rtf)
display as text "***************"


display as text "***************"
display as text "Actions vs PolParties"
asdoc tabulate action polpart, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02d.Tab-PolPart.rtf)
display as text "***************"


display as text "***************"
display as text "Actions vs Justice"
asdoc tabulate action justice, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02e.Tab-Justice.rtf)
display as text "***************"



display as text "***************"
display as text "Actions vs Armed Forces"
asdoc tabulate action armed, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02f.Tab-Armed.rtf)
display as text "***************"


display as text "***************"
display as text "Actions vs Police"
asdoc tabulate action police, ///
chi2 row replace ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\02g.Tab-Police.rtf)
display as text "***************"


log close



//Correlations of Variables
cd d:/
asdoc pwcorr action std_trust parliament govt polpart justice armed police if democr==0 , ///
star(all) replace nonum spearman ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\03.Corr-NonDemocr.rtf)

cd d:/
asdoc pwcorr action std_trust parliament govt polpart justice armed police if democr==1 , ///
star(all) replace nonum spearman  ///
save(D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\03.Corr-Democr.rtf)






//Collapsed Graphical Appendicies
collapse (mean) action act_pol std_trust parliament govt polpart justice armed police, by(ccode democr COW_ALPHA)

label var action "Avg. Guttman Scale Political Action"
label var act_pol "Avg. Binary Political Action"
label var std_trust "Normalized Trust Sum"
label var parliament "Avg. Trust to Parliament"
label var govt "Avg. Trust to Government"
label var polpart "Avg. Trust to PolParties"
label var justice "Avg. Trust to Justice"
label var armed "Avg. Trust to Armed Forces"
label var police "Avg. Trust to Police"


egen clock = mlabvpos(action std_trust)
twoway (scatter action std_trust if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action std_trust if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action std_trust if democr==0,  lpattern(dash) ) ///
(lfit action std_trust if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust (Normalized)", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\20.TrustSum.png", as(png) replace


drop clock
egen clock = mlabvpos(action parliament)
twoway (scatter action parliament if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action parliament if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action parliament if democr==0,  lpattern(dash) ) ///
(lfit action parliament if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Parliament", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\21.Parliament.png", as(png) replace

drop clock
egen clock = mlabvpos(action govt)
twoway (scatter action govt if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action govt if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action govt if democr==0,  lpattern(dash) ) ///
(lfit action govt if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Government", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\22.Govt.png", as(png) replace

drop clock
egen clock = mlabvpos(action polpart)
twoway (scatter action polpart if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action polpart if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action polpart if democr==0,  lpattern(dash) ) ///
(lfit action polpart if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Political Parties", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\23.PolPart.png", as(png) replace

drop clock
egen clock = mlabvpos(action justice)
twoway (scatter action justice if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action justice if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action justice if democr==0,  lpattern(dash) ) ///
(lfit action justice if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Justice", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\24.Justice.png", as(png) replace

drop clock
egen clock = mlabvpos(action armed)
twoway (scatter action armed if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action armed if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action armed if democr==0,  lpattern(dash) ) ///
(lfit action armed if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Armed Forces", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\25.Armed.png", as(png) replace

drop clock
egen clock = mlabvpos(action police)
twoway (scatter action police if democr==0, mlabsize(*.7) mlabvpos(clock) mlabel(COW_ALPHA) msymbol(T))  ///
(scatter action police if democr==1, mlabsize(*.7) mlabvpos(clock)  mlabel(COW_ALPHA)   ) ///
(lfit action police if democr==0,  lpattern(dash) ) ///
(lfit action police if democr==1,  lpattern(vshortdash) ), ///
ytitle("Average # of  Action", margin(medium)) ///
xtitle("Average Institutional Trust to Police", margin(small)) ///
legend(order(1 "Non-Democratic" 2 "Democratic"))
graph export  "D:\GDrive\_My_Research\PolTrust-NEPP-Paper\FirstCase-Paper\05.Res\Graphics\26.Police.png", as(png) replace


*********************************************************************************







outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01a.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx
*Basic Model, Wave Effect
display as text "***Model 01a"
poisson gutt_action gutt_instrust3 gutt_instrust3_sq $dwave, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01a.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx



*Basic Model, Wave Effect, Type Effect
display as text "***Model 01b"
poisson gutt_action gutt_instrust3 gutt_instrust3_sq $dwave $dtype, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01b.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx

*Basic Model, Wave Effect, Country Effect
display as text "***Model 01b"
poisson gutt_action gutt_instrust3 gutt_instrust3_sq $dwave $dcountry , robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01b.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx




*Basic Model-Polarized
display as text "***Model 03a"
poisson gutt_action_pol gutt_instrust3 gutt_instrust3_sq, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03a.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx
*Basic Model, Wave Effect
display as text "***Model 03a"
poisson gutt_action_pol gutt_instrust3 gutt_instrust3_sq $dwave, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03a.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx



*Basic Model-Polarized, Wave Effect, Type Effect
display as text "***Model 03b"
poisson gutt_action_pol gutt_instrust3 gutt_instrust3_sq $dwave $dtype, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03b.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx

*Basic Model-Polarized, Wave Effect, Country Effect
display as text "***Model 03b"
poisson gutt_action_pol gutt_instrust3 gutt_instrust3_sq $dwave $dcountry , robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03b.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\03b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx





*Basic Model-Grouped
display as text "***Model 03a"
poisson gutt_action_gr gutt_instrust3 gutt_instrust3_sq, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05a.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx
*Basic Model-Grouped, Wave Effect
display as text "***Model 03a"
poisson gutt_action_gr gutt_instrust3 gutt_instrust3_sq $dwave, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05a.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05a.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx



*Basic Model-Grouped, Wave Effect, Type Effect
display as text "***Model 03b"
poisson gutt_action_gr gutt_instrust3 gutt_instrust3_sq $dwave $dtype, robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05b.PoissonReg.tex, dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx

*Basic Model-Grouped, Wave Effect, Country Effect
display as text "***Model 03b"
poisson gutt_action_gr gutt_instrust3 gutt_instrust3_sq $dwave $dcountry , robust
mfx
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\05b.PoissonReg.tex, dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)') 
outreg2 using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Regs\01b.PoissonReg.tex, dec(3) tex ctitle(ME) label mfx


log close



//Logit Guttman Regression Scaling results
use preserved.dta,clear

//Global Variables
global dwave DWave_5 DWave_4 DWave_3 DWave_2 DWave_1
global dcountry  DCountry_80	 DCountry_79	 DCountry_78	 DCountry_77	 DCountry_76	 DCountry_75	 DCountry_74	 DCountry_73	 DCountry_72	 DCountry_71	 DCountry_70	 DCountry_69	 DCountry_68	 DCountry_67	 DCountry_66	 DCountry_65	 DCountry_64	 DCountry_63	 DCountry_62	 DCountry_61	 DCountry_60	 DCountry_59	 DCountry_58	 DCountry_57	 DCountry_56	 DCountry_55	 DCountry_54	 DCountry_53	 DCountry_52	 DCountry_51	 DCountry_50	 DCountry_49	 DCountry_48	 DCountry_47	 DCountry_46	 DCountry_45	 DCountry_44	 DCountry_43	 DCountry_42	 DCountry_41	 DCountry_40	 DCountry_39	 DCountry_38	 DCountry_37	 DCountry_36	 DCountry_35	 DCountry_34	 DCountry_33	 DCountry_32	 DCountry_31	 DCountry_30	 DCountry_29	 DCountry_28	 DCountry_27	 DCountry_26	 DCountry_25	 DCountry_24	 DCountry_23	 DCountry_22	 DCountry_21	 DCountry_20	 DCountry_19	 DCountry_18	 DCountry_17	 DCountry_16	 DCountry_15	 DCountry_14	 DCountry_13	 DCountry_12	 DCountry_11	 DCountry_10	 DCountry_9	 DCountry_8	 DCountry_7	 DCountry_6	 DCountry_5	 DCountry_4	 DCountry_3	 DCountry_2	 DCountry_1
global dType DType_3 DType_2 DType_1 

*Logit Reg sonuclar ve marjinal etkiler
log using D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\02.Logit.Outputs.txt, text replace

*Basic Model
*petition_pol boycotts_pol demonst_pol act act_pol



*Basic Model
display as text "***Model 12a"
logit polactivity	gutt_instrust3 gutt_instrust3_sq, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 12a"
logit polactivity	gutt_instrust3 gutt_instrust3_sq $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 12b"
logit polactivity	gutt_instrust3 gutt_instrust3_sq $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 12b"
logit polactivity	gutt_instrust3 gutt_instrust3_sq $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\10b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

log close



*Basic Model
display as text "***Model 12a"
logit petition_pol parliament  govt  polpart  justice3  armed  police, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 12a"
logit petition_pol parliament  govt  polpart  justice3  armed  police $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 12b"
logit petition_pol parliament  govt  polpart  justice3  armed  police $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 12b"
logit petition_pol parliament  govt  polpart  justice3  armed  police $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\12b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 



*Basic Model
display as text "***Model 14a"
logit boycotts_pol parliament  govt  polpart  justice3  armed  police, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 14a"
logit boycotts_pol parliament  govt  polpart  justice3  armed  police $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 14b"
logit boycotts_pol parliament  govt  polpart  justice3  armed  police $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 14b"
logit boycotts_pol parliament  govt  polpart  justice3  armed  police $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\14b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx




*Basic Model
display as text "***Model 16a"
logit demonst_pol parliament  govt  polpart  justice3  armed  police, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 16a"
logit demonst_pol parliament  govt  polpart  justice3  armed  police $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 16b"
logit demonst_pol parliament  govt  polpart  justice3  armed  police $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 16b"
logit demonst_pol parliament  govt  polpart  justice3  armed  police $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\16b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx





*Basic Model
display as text "***Model 18a"
logit act parliament  govt  polpart  justice3  armed  police, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 18a"
logit act parliament  govt  polpart  justice3  armed  police $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 18b"
logit act parliament  govt  polpart  justice3  armed  police $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 18b"
logit act parliament  govt  polpart  justice3  armed  police $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\18b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx





*Basic Model
display as text "***Model 20a"
logit act_pol parliament  govt  polpart  justice3  armed  police, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20a.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves
display as text "***Model 20a"
logit act_pol parliament  govt  polpart  justice3  armed  police $dwave, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20a.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20a.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 

*Basic Model, Waves, Types
display as text "***Model 20b"
logit act_pol parliament  govt  polpart  justice3  armed  police $dwave $dType, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20b.LogisticReg.tex", dec(3) tex replace label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx 
*Basic Model, Waves, Countries
display as text "***Model 20b"
logit act_pol parliament  govt  polpart  justice3  armed  police $dwave $dcountry, robust
mfx
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20b.LogisticReg.tex", dec(3) tex label ///
addstat( Wald Chi2, `e(chi2)', Prob>Chi2, `e(p)',Pseudo R-squared, `e(r2_p)')
outreg2 using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\20b.LogisticReg.tex", dec(3) tex ctitle(ME) label mfx




log close




poisson gutt_action gutt_instrust i.Type, robust
poisson gutt_action gutt_instrust i.Type i.Wave i.ccode, robust

    sysuse auto, clear
    logit foreign mpg rep78 head
    mfx compute
    outreg2 using myfile, replace
    outreg2 using myfile, mfx ctitle(mfx) see tex


histogram gutt_instrust
histogram gutt_action
histogram gutt_action_pol
histogram gutt_action_gr

meanparliament

eststo
esttab using logitmfx.tex, margin replace






//Old Analyses



//Genel Gorunum
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Logits\_Outputs\00.Wave_Asks.txt", text replace
foreach z of global allvars {
	tab `z' Wave, chi col taub V
}
log close




//Wave_Var bazinda tabulations
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\01.Tabulations_Wave&Vars.txt", text replace
display as text "***Tabulation"
foreach x of global action {
display as text "***Tabulation of `x'"
tab  Wave `x'
tab  Type `x'
display as text "___________"
display _newline(5)
}

display as text "***Tabulation"
foreach x of global action_pol {
display as text "***Tabulation of `x'"
tab  Wave `x'
tab  Type `x'
display as text "___________"
display _newline(5)
}


display as text "***Tabulation"
foreach x of global action_gr {
display as text "***Tabulation of `x'"
tab  Wave `x'
tab  Type `x'
display as text "___________"
display _newline(5)
}

foreach x of global confid {
display as text "***Tabulation of `x'"
tab  Wave `x'
tab  Type `x'
display as text "___________"
display _newline(5)
}

foreach x of global action {
	foreach y of global confid {
		forval Wave=2(1)6		{
display as text "***Tabulation of `x' and `y' if Wave=`Wave'"
tab `y' `x',chi row col
display as text "___________"
display _newline(5)
}
}
}

foreach x of global action_pol {
	foreach y of global confid {
		forval Wave=2(1)6		{
display as text "***Tabulation of `x' and `y' if Wave=`Wave'"
tab `y' `x',chi row col
display as text "___________"
display _newline(5)
}
}
}

foreach x of global action_gr {
	foreach y of global confid {
		forval Wave=2(1)6		{
display as text "***Tabulation of `x' and `y' if Wave=`Wave'"
tab `y' `x',chi row col
display as text "___________"
display _newline(5)
}
}
}
log close

//Tabulations by Type
foreach x of global action {
foreach y of global confid {
forval i=0(1)2{
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Tabulations\byType\Action_`x'_Confid_`y'_Type_`i'.txt", text replace
display as text "***Tabulation of `x' and `y' in Type=`i'"
tab  `y' `x' if Type==`i', chi row col
display as text "___________"
display _newline(5)
log close
}
}
}

foreach x of global action {
foreach y of global confid {
forval i=1(1)99{
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Tabulations\byCountry\Action_`x'_Confid_`y'_Country_`i'.txt", text replace
display as text "***Tabulation of `x' and `y' in Country=`i'"
tab1 S003 if ccode==`i'
tab  `y' `x' if ccode==`i', chi row col
display as text "___________"
display _newline(5)
log close
}
}
}


//Descriptives
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\02.Desriptives.txt", text replace
display as text "***Descriptives"
eststo clear
qui:estpost tabstat $allvars $action_pol $action_gr, stats(N min median max range sd var skewness kurtosis) columns(statistics)
esttab ., cells("count(label(Count)) min(label(Min)) p50(label(Median)) max(label(Max)) range(label(Range)) sd(label(StDev)) variance(label(Variance)) skewness(label(Skewness)) kurtosis(label(Kurtosis))") label ///
title("Descriptives for Confidence & Actions")  nomtitles nonumbers
display _newline(5)
log close


//Models
log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\03a.Models.Action.txt", text replace
foreach a of global action{
display as text "***Normal Mlogit of Var `a'"
eststo a1:mlogit `a' $confid , robust base(3)
eststo a2:margins, dydx(*) 
eststo a3:mlogit `a' $confid i.Wave, robust base(3)
eststo a4:margins, dydx(*)
eststo a5:mlogit `a' $confid i.Wave i.Type , robust base(3)
eststo a6:margins, dydx(*) 
display _newline(5)
}
log close

log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\03b.Models.Polar.txt", text replace
foreach b of global action_pol{
display as text "***Logit of Var `b' Polarized "
eststo b1:logit `b' $confid, robust
eststo b2:margins, dydx(*)
eststo b3:logit `b' $confid i.Wave, robust
eststo b4:margins, dydx(*)
eststo b3:logit `b' $confid i.Wave i.Type, robust
eststo b4:margins, dydx(*)
display _newline(5)
}
log close

log using "D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\03c.Models.Grouped.txt", text replace
foreach c of global action_gr{
display as text "***Logit of Var `b' Grouped "
eststo c1:logit `c' $confid, robust
eststo c2:margins, dydx(*)
eststo c3:logit `c' $confid i.Wave, robust
eststo c4:margins, dydx(*)
eststo c5:logit `c' $confid i.Wave i.Type, robust
eststo c6:margins, dydx(*)
display _newline(5)
}
log close


end


//Collapse of Variables
foreach var of global allvars{
egen mean`var'=mean(`var'), by(CountryId Wave)
}

foreach var of varlist gutt_action gutt_instrust{
egen mean`var'=mean(`var'), by(CountryId Wave)
}

 twoway (connected meanparliament Wave if Type==1, sort)
//Graphicsl Representations
graph twoway (connected  meanparliament Wave if Type==1,sort lwidth(medthick)) (connected  meangovt Wave if Type==1,sort lwidth(medthick)) ///
(connected  meanpolpart Wave if Type==1,sort lwidth(medthick)) (connected  meanjustice Wave if Type==1,sort lwidth(medthick)) ///
(connected  meanarmed Wave if Type==1,sort lwidth(medthick)) (connected  meanpolice Wave if Type==1,sort lwidth(medthick)) ///
, title(Democratic) scheme(sj)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\01_Confidences_Type1.png,as(png) replace

graph twoway (connected  meanparliament Wave if Type==2,sort lwidth(medthick)) (connected  meangovt Wave if Type==2,sort lwidth(medthick)) ///
(connected  meanpolpart Wave if Type==2,sort lwidth(medthick)) (connected  meanjustice Wave if Type==2,sort lwidth(medthick)) ///
(connected  meanarmed Wave if Type==2,sort lwidth(medthick)) (connected  meanpolice Wave if Type==2,sort lwidth(medthick)) ///
, title(NonDemocratic) scheme(sj)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\02_Confidences_Type2.png,as(png) replace




***Drop
global allmeans meanparliament meangovt meanpolpart meanjustice meanarmed meanpolice meanpetition meanboycotts meandemonst meanstrikes
local forlab: value label S003
foreach var of global allmeans{
local label: label `forlab' `i'
di "`label'"
cap:graph twoway (bar `var' Wave if ccode==`i', fcolor(none)) (connected `var' Wave if ccode==`i',  sort) , title(`label')
cap:graph export  D:\`i'_`label'_`var'.png,as(png) replace
}
}


sysuse auto, clear
local forlab: value label foreign
forvalues x = 0(1)1 {
local label: label `forlab' `x'
di "`label'"
graph twoway scatter price mpg if foreign == `x', by(rep78) saving(wtbywk`label', replace) title("Wt/Wk Group =`label'") 
}





//Graphical Appendicies
use preserved.dta,replace

twoway (qfit gutt_action4 gutt_instrust3 if Type==0,  lpattern(dash)) ///
(qfit gutt_action4 gutt_instrust3,  lpattern(solid)) ///
(qfit gutt_action4 gutt_instrust3 if Type==2,  lpattern(vshortdash)), ///
ytitle(Guttman Scale of Political Action, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Political Action and Political Trust)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Nondemocratic" 2 "Overall" 3 "Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\01_AllIndividuals.png,as(png) replace


twoway (qfit  petition gutt_instrust3 if Type==0,  lpattern(dash)) ///
(qfit petition gutt_instrust3 ,  lpattern(solid)) ///
(qfit petition gutt_instrust3 if Type==2,  lpattern(vshortdash)), ///
ytitle(Petition, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Petition and Political Trust)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Nondemocratic" 2 "Overall" 3 "Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\02_All_Petition.png,as(png) replace



twoway (qfit  demonst gutt_instrust3 if Type==0,  lpattern(dash)) ///
(qfit demonst gutt_instrust3,  lpattern(solid)) ///
(qfit demonst gutt_instrust3 if Type==2,  lpattern(vshortdash)), ///
ytitle(Demonstration, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Demonstration and Political Trust)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Nondemocratic" 2 "Overall" 3 "Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\03_All_Demonst.png,as(png) replace


twoway (qfit  boycotts gutt_instrust3 if Type==0,  lpattern(dash)) ///
(qfit boycotts gutt_instrust3 ,  lpattern(solid)) ///
(qfit boycotts gutt_instrust3 if Type==2,  lpattern(vshortdash)), ///
ytitle(Boycotts, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Boycotts and Political Trust)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Nondemocratic" 2 "Overall" 3 "Democratic" ///
) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\04_All_Boycotts.png,as(png) replace


//Collapsed Graphical Appendicies
collapse (mean) gutt_action gutt_action4 gutt_instrust gutt_instrust3 gutt_action_pol gutt_action_gr gutt_action4_pol gutt_action4_gr, by(CountryId Type cabbrev)

label var gutt_action "Guttman Scale of Political Action"
label var gutt_action "Guttman Scale of Political Action"
label var gutt_action_pol "Guttman Scale of Political Action-Polarized"
label var gutt_action4_pol "Guttman Scale of Political Action-Polarized"
label var gutt_action_gr "Guttman Scale of Political Action-Grouped"
label var gutt_action4_gr "Guttman Scale of Political Action-Grouped"
label var gutt_instrust "Sum of Institutional Confidence"
label var gutt_instrust3 "Sum of Institutional Confidence"


twoway (scatter gutt_action4 gutt_instrust3 if Type==0, msymbol(0h)) ///
(scatter gutt_action4 gutt_instrust3  if Type==1,msymbol(S)) ///
(scatter gutt_action4 gutt_instrust3  if Type==2, msymbol(T)) ///
(qfit gutt_action4 gutt_instrust3 if Type==0,  lpattern(dash)) ///
(qfit gutt_action4 gutt_instrust3 if Type==1,  lpattern(vshortdash)) ///
(qfit gutt_action4 gutt_instrust3 if Type==2,  lpattern(solid)), ///
ytitle(Guttman Scale of Political Action, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Political Action and Institutional Trust)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Nondemocratic" 2 "Mixed Regimes" 3 "Democratic" ///
4 "Quadratic.NonD"  ///
5 "Quadratic.Mix" ///
6 "Quadratic.Dem" ) nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\11.All_CountryLevel.png,as(png) replace


//Scatter grafikleri Type bazında
twoway (scatter gutt_action gutt_instrust, mlabel(cabbrev)) (lowess gutt_action gutt_instrust) (qfit gutt_action gutt_instrust) if Type==1, ///
ytitle(Guttman Scale of Political Action, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Political Action and Institutional Trust - Mixed Regime Countries)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Guttman Scale Political Action" 2 "Lowess Curve - Smoothed" 3 "Quadratic Fitted Values")nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\12.Democratics.png,as(png) replace


twoway (scatter gutt_action gutt_instrust, mlabel(cabbrev)) (lowess gutt_action gutt_instrust) (qfit gutt_action gutt_instrust) if Type==2, ///
ytitle(Guttman Scale of Political Action, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Political Action and Institutional Trust - Democratic Countries)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Guttman Scale Political Action" 2 "Lowess Curve - Smoothed" 3 "Quadratic Fitted Values")nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\13.NonDemocratics.png,as(png) replace

twoway (scatter gutt_action gutt_instrust, mlabel(cabbrev)) (lowess gutt_action gutt_instrust) (qfit gutt_action gutt_instrust) if Type==0, ///
ytitle(Guttman Scale of Political Action, margin(medium)) xtitle(Sum of Institutional Trust, margin(small)) ///
title(Political Action and Institutional Trust - Nondemocratic Regime)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Guttman Scale Political Action" 2 "Lowess Curve - Smoothed" 3 "Quadratic Fitted Values")nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\14.Mixeds.png,as(png) replace





//Wave değişimleri Type bazında
use preserved.dta,replace
collapse (mean) gutt_action gutt_instrust gutt_action_pol gutt_action_gr parliament govt polpart justice armed police ///
petition boycotts demonst strikes petition_pol boycotts_pol demonst_pol strikes_pol petition_gr boycotts_gr demonst_gr strikes_gr, by(Wave Type)

label var parliament "Mean Confidence to Parliament"
label var govt "Mean Confidence to Gov't"
label var polpart "Mean Confidence to Political Parties"
label var justice "Mean Confidence to Justice"
label var armed "Mean Confidence to Army"
label var police "Mean Confidence to Police"


graph twoway (connected parliament Wave if Type==0,sort lwidth(medthick)) (connected govt Wave if Type==0,sort lwidth(medthick)) ///
(connected polpart Wave if Type==0,sort lwidth(medthick)) (connected justice Wave if Type==0,sort lwidth(medthick)) ///
(connected armed Wave if Type==0,sort lwidth(medthick)) (connected police Wave if Type==0,sort lwidth(medthick)) ///
,ytitle(Mean Confidence, margin(medium)) xtitle(Waves, margin(small)) ///
title(Institutional Confidence of NonDemocratic by Wave)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Parliament" 2 "Gov't" 3 "Political Parties" 4 "Justice" 5 "Army" 6 "Police") nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\31.Conf.Wave_Type0.png,as(png) replace

graph twoway (connected parliament Wave if Type==1,sort lwidth(medthick)) (connected govt Wave if Type==1,sort lwidth(medthick)) ///
(connected polpart Wave if Type==1,sort lwidth(medthick)) (connected justice Wave if Type==1,sort lwidth(medthick)) ///
(connected armed Wave if Type==1,sort lwidth(medthick)) (connected police Wave if Type==1,sort lwidth(medthick)) ///
,ytitle(Mean Confidence, margin(medium)) xtitle(Waves, margin(small)) ///
title(Institutional Confidence of Mixed Regime by Wave)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Parliament" 2 "Gov't" 3 "Political Parties" 4 "Justice" 5 "Army" 6 "Police") nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\32.Conf.Wave_Type1.png,as(png) replace

graph twoway (connected parliament Wave if Type==2,sort lwidth(medthick)) (connected govt Wave if Type==2,sort lwidth(medthick)) ///
(connected polpart Wave if Type==2,sort lwidth(medthick)) (connected justice Wave if Type==2,sort lwidth(medthick)) ///
(connected armed Wave if Type==2,sort lwidth(medthick)) (connected police Wave if Type==2,sort lwidth(medthick)) ///
,ytitle(Mean Confidence, margin(medium)) xtitle(Waves, margin(small)) ///
title(Institutional Confidence of Democratic by Wave)  xsize(20) ysize(15) scale(0.8) ///
scheme(sj) legend(order(1 "Parliament" 2 "Gov't" 3 "Political Parties" 4 "Justice" 5 "Army" 6 "Police") nocolfirst rows(3) rowgap(small) colgap(zero) span)
graph export  D:\Dropbox\_My_Research\Protests-Adil\FirstCase-Paper\04.Res\_Outputs\Graphics\33.Conf.Wave_Type2.png,as(png) replace




*NOTES
**keep S003 con S007_01
**export delimited using "D:\Dropbox\_My_Research\Protests_etall\_Data\wvs_long.csv", replace
***Transitions
*
*************************************************************************************************************************
***1stRQ
*
**E025	Political action: signing a petition
**E025B	Political action recently done: signing a petition
**Current	:W1,2,3,4,5,6
**Recently	:W1,5,6
*/////E025	Political action: signing a petition		2	[-99,-1]	
*1:Have done
*2:Might do
*3:Would never do
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Don't know
*/////E025B	Political action recently done: signing a petition		2	[-99,-1]	
*1:Have done
*2:Not done
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Don't know
*
*
*************************************************************************************************************************
***2stRQ
*
**E026	Political action: joining in boycotts
**E026B	Political action recently done: joining in boycotts
**Current	:W1,2,3,4,5,6
**Recently	:W1,5,6
*/////E026	Political action: joining in boycotts		2	[-99,-1]	
*1:Have done
*2:Might do
*3:Would never do
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Don't know
*
*/////E026B	Political action recently done: joining in boycotts		2	[-99,-1]	
*1:Have done
*2:Not done
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Don't know
*
*
*************************************************************************************************************************
***3stRQ
*
**E028	Political action: joining unofficial strikes
**E028B	Political acition recently done: Joining strikes
**Current	:W1,2,3,4,5,6
**Recently	:W1,5,6
*/////E028	Political action: joining unofficial strikes		2	[-99,-1]	
*1:Have done
*2:Might do
*3:Would never do
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know
*/////E028B	Political acition recently done: Joining strikes		2	[-99:-1]	
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know
*1:Have done
*2:Not done
*
*
*************************************************************************************************************************
***4stRQ
*
**E027	Political action: attending lawful/peaceful demonstrations
**E221B  Political action recently done: Attending peaceful/lawful demonstrations
**Current	:W1,2,3,4,5,6
**Recently	:W1,5,6
*/////E027	Political action: attending lawful/peaceful demonstrations		2	[-99,-1]	
*1:Have done
*2:Might do
*3:Would never do
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know
*/////E221B	Political action recently done: Attending peaceful/lawful demonstrations		2	[-99,-1]	
*1:Have done
*2:Not done
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know
*"
*
*
*
*************************************************************************************************************************
***5stRQ
*
**E222	Political action: Other
**E222B	Political action recently done: Other
**Current	:W1,2,3,4,5,6
**Recently	:W1,5,6
*/////E222	Political action: Other		2	[-99:-1]	
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know
*1:Have done
*2:Might do
*3:Would never do
*/////E222B	Political action recently done: Other		2	[-99,-1]	
*1:Have done
*2:Not done
*-5:Missing; Unknown
*-4:Not asked in survey
*-3:Not applicable
*-2:No answer
*-1:Donմ know



ssc inst estout
sysuse auto
xi: logit foreign price i.rep78
mfx
eststo
esttab using logitmfx.tex, margin replace
